package mtt.us.client.views.fachbereich.studiengang.editor;

import mtt.us.client.events.GetModelDataEvent;
import mtt.us.client.events.SetModelDataEvent;
import mtt.us.dto.StudiengangDTO;
import hmvc4gwt.client.event.HmvcEvent;
import hmvc4gwt.client.event.HmvcEventListener;
import hmvc4gwt.client.model.Model;

public class StudiengangEditorModel extends Model implements HmvcEventListener {
	
	private StudiengangDTO studiengang; 

	public StudiengangEditorModel(StudiengangDTO studiengang) {
		setStudiengang(studiengang);
	}

	public StudiengangEditorModel() {
	}
	
	public void doInit() {
		
		getController().register(GetModelDataEvent.class, this);
	}

	private StudiengangDTO getStudiengang() {
		return studiengang;
	}

	private void setStudiengang(StudiengangDTO studiengang) {
		this.studiengang = studiengang;
	}

	public void handleEvent(HmvcEvent event) {
		
		if (event instanceof GetModelDataEvent) {
			
			getController().fireLocalEvent(new SetModelDataEvent(getStudiengang()));
			
		}
	}

}
